<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
       
      <meta name="keywords" content="hi~" />
       
      <meta name="description" content="梦见新大陆" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title> 默</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css"
      />
      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="默" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover1.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">默</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-interview-question-http"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/09/11/interview-question-http/"
    >综合面试题</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/09/11/interview-question-http/" class="article-date">
  <time datetime="2021-09-11T14:23:00.000Z" itemprop="datePublished">2021-09-11</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E9%9D%A2%E8%AF%95%E9%A2%98/">面试题</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h4 id="一、计算机网络"><a href="#一、计算机网络" class="headerlink" title="一、计算机网络"></a>一、计算机网络</h4><h5 id="1-浏览器的缓存机制"><a href="#1-浏览器的缓存机制" class="headerlink" title="1. 浏览器的缓存机制"></a>1. 浏览器的缓存机制</h5><h5 id="2-babel与ployfill的关系和区别"><a href="#2-babel与ployfill的关系和区别" class="headerlink" title="2. babel与ployfill的关系和区别"></a>2. babel与ployfill的关系和区别</h5><h5 id="3-解决跨域的方法"><a href="#3-解决跨域的方法" class="headerlink" title="3. 解决跨域的方法"></a>3. 解决跨域的方法</h5><h5 id="4-http状态码"><a href="#4-http状态码" class="headerlink" title="4. http状态码"></a>4. http状态码</h5><h5 id="5-git-stash"><a href="#5-git-stash" class="headerlink" title="5. git stash"></a>5. git stash</h5><h5 id="6-localstorage跨域可以共享吗，如何解决"><a href="#6-localstorage跨域可以共享吗，如何解决" class="headerlink" title="6. localstorage跨域可以共享吗，如何解决"></a>6. localstorage跨域可以共享吗，如何解决</h5><h5 id="7-描述url到页面渲染的整个过程"><a href="#7-描述url到页面渲染的整个过程" class="headerlink" title="7. 描述url到页面渲染的整个过程"></a>7. 描述url到页面渲染的整个过程</h5><h5 id="8-https页面引入http资源的解决方式-如何让网站同时兼容http和https"><a href="#8-https页面引入http资源的解决方式-如何让网站同时兼容http和https" class="headerlink" title="8. https页面引入http资源的解决方式/如何让网站同时兼容http和https"></a>8. https页面引入http资源的解决方式/如何让网站同时兼容http和https</h5><h5 id="9-cookie、session、sessionStorage和localStorage的-区别"><a href="#9-cookie、session、sessionStorage和localStorage的-区别" class="headerlink" title="9. cookie、session、sessionStorage和localStorage的 区别"></a>9. cookie、session、sessionStorage和localStorage的 区别</h5><h5 id="10-http-和-https-的区别"><a href="#10-http-和-https-的区别" class="headerlink" title="10. http 和 https 的区别"></a>10. http 和 https 的区别</h5> 
      <a class="article-more-link" href="/2021/09/11/interview-question-http/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/webpack/" rel="tag">webpack</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" rel="tag">计算机网络</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9D%A2%E8%AF%95%E9%A2%98/" rel="tag">面试题</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-sso"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/05/06/sso/"
    >单点登录实现</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/05/06/sso/" class="article-date">
  <time datetime="2021-05-06T05:14:30.000Z" itemprop="datePublished">2021-05-06</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h5 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h5><p>在日常生活中，很多人由于忘记某些网站的登录密码而烦恼，因为大多数用户都要记忆不少于 10 个用户名和相应密码。随着信息化飞速发展，大型企业和政府部门等都开始使用电子系统进行办公，整个办公系统由多个不同的子系统构成，如办公自动化(OA)系统，财务管理系统，档案管理系统，信息查询系统等。如果每个系统都使用独立的登录和验证机制，那么每天工作人员都要登录不同的系统进行办公。用户登录的频繁操作，降低了员工的工作效率，造成工作成本的浪费。而大量的密码和用户名的记忆时间长了也会出现问题，忘记密码或者混淆密码都会造成很大的麻烦。基于以上原因，为用户提供一个畅通的登录通道变得十分重要。</p>
<p>这时候用户希望我在一个系统登录之后可以默认在它的关联系统（二级域名必须相同）中也是已登录状态，避免繁琐的多次登录。这时候就需要 SSO（Single Sign On）来帮助我们实现。</p>
<p>单点登录(SingleSign-On，SSO)是一种帮助用户快捷访问网络中多个站点的安全通信技术。单点登录系统基于一种安全的通信协议，该协议通过多个系统之间的用户身份信息的交换来实现单点登录。使用单点登录系统时，用户只需要登录一次，就可以访问多个系统。</p>
<h5 id="实现思路"><a href="#实现思路" class="headerlink" title="实现思路"></a>实现思路</h5><blockquote>
<p>Cookie 作为凭证媒介</p>
</blockquote>
<p>众所周知，HTTP 是无状态的协议，这意味着服务器无法确认用户的信息。于是，W3C 就提出了：给每一个用户都发一个通行证，用户访问站点时都要携带通行证，这样服务器就可以从通行证上确认用户的信息，通行证就是 Cookie。</p>
<p>同样因为 HTTP 协议是无状态的，Session 不能依据 HTTP 连接来判断是否为同一个用户。于是：服务器向客户端发送了一个名为 SESSIONID 的 Cookie，它的值是 Session 的 id 值。其实 Session 是依据 Cookie 来识别是否是同一个用户。</p>
<blockquote>
<p>通过页面重定向的方式</p>
</blockquote>
<h5 id="逻辑流程图"><a href="#逻辑流程图" class="headerlink" title="逻辑流程图"></a>逻辑流程图</h5> 
      <a class="article-more-link" href="/2021/05/06/sso/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SSO/" rel="tag">SSO</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-rights-mgt"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/03/11/rights-mgt/"
    >权限管理的原理</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/03/11/rights-mgt/" class="article-date">
  <time datetime="2021-03-11T09:44:30.000Z" itemprop="datePublished">2021-03-11</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h5 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h5><p>在一些中后台项目的业务中经常会有给不同的用户看到不同的页面甚至不同的操作权限，这时候权限管理功能就闪亮登场了，用它来给用户赋予不同的角色，给不同的角色设置不同的权限，那么前后端在技术方面具体是如何实现的呢？带着这个问题我们来看下权限管理的流程和实现原理。</p>
<h5 id="实现原理"><a href="#实现原理" class="headerlink" title="实现原理"></a>实现原理</h5><blockquote>
<p>权限管理大致方案就是给角色分配权限，给用户分配角色。根据业务不同要求的颗粒度不同，如果颗粒度仅限于路由级别，实现思路大致如下</p>
</blockquote>
<p>首先，前端需要分别定义一套（不需权限所有已登陆用户都可访问）静态路由表和动态路由表，路由元信息中包含这个路由对应的（和后端定义好的）权限名。</p> 
      <a class="article-more-link" href="/2021/03/11/rights-mgt/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vue-%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86/" rel="tag">-vue - 权限管理</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-gwt-token"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/27/gwt-token/"
    >WEB应用中的权限认证</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/01/27/gwt-token/" class="article-date">
  <time datetime="2021-01-27T17:25:17.000Z" itemprop="datePublished">2021-01-27</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%8D%95%E7%82%B9%E7%99%BB%E5%BD%95/">单点登录</a> / <a class="article-category-link" href="/categories/%E5%8D%95%E7%82%B9%E7%99%BB%E5%BD%95/GWT/">GWT</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="1-传统方案——基于-cookie-session-的解决方案"><a href="#1-传统方案——基于-cookie-session-的解决方案" class="headerlink" title="1.传统方案——基于 cookie/session 的解决方案"></a>1.传统方案——基于 cookie/session 的解决方案</h3><p>首先，浏览器端向服务端发送 login 请求，把用户名和密码都发送过去，服务器验证用户名密码正确，然后就会创建对应的 session 数据并保存在内存或者数据库中。然后，服务器返回一个 HTTP 200 OK 的 response，这个 response 会有个 header 叫 set-Cookie：sessionid=xxx，浏览器拿到这个 response 以后，因为有 set-Cookie 这个 header， 带上唯一的 id sessionid（set-Cookie：sessionid=xxx），它就会把 cookie 保存在浏览器中，下次我们再访问这个需要权限的接口，这时候会自动把 cookie 带上。服务器端就可以使用 cookie 中的信息 sessionid，查看服务器中是否存在这个 session 的数据，如果存在则返回对应的信息，否则返回 401 Not authorized。</p>
<p>基于 cookie 的身份验证是有状态的，意味着这个验证记录或者会话必须同时保存在服务器端和客户端，服务器要跟踪记录 session 并且存至内存或者数据库，同时前端在 cookie 也要保存这个 sessionid 作为 session 唯一的标识符。这种模式的问题在于扩展性不好。假如只有一台服务器当然没有问题，假如是一个服务器集群，这就要求 session 的数据共享，我们需要每台服务器都读取到这个 session，一种解决方案就是 session 的数据持久化，把数据写到持久层中去，各种服务收到请求以后都向持久层发送数据。这种方案优点是架构清晰，缺点是工程量比较大，另外，持久层如果挂了，那么就单点失败。<br><img width="600px" style="display:block;margin:20px auto;" src="/2021/01/27/gwt-token/1.jpeg"></p> 
      <a class="article-more-link" href="/2021/01/27/gwt-token/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/GWT/" rel="tag">GWT</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-nginx"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/22/nginx/"
    >nginx入门</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/01/22/nginx/" class="article-date">
  <time datetime="2021-01-22T17:41:54.000Z" itemprop="datePublished">2021-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Nginx/">Nginx</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h4 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h4><p>nginx 是 web 服务器，由 C 语言开发，基于事件驱动能处理百万级别的 tcp 连接，高度模块化的设计和自由的许可证使得扩展其功能的模块层出不穷，跨平台，可使用当前操作系统特有的一些高效 API 来提高自己的性能，nginx 以性能为王。选择 nginx 的核心理由是处理高并发请求的同时保持高效的服务。<br>Nginx 特点：<br>适合前后端分离开发、保证安全、nginx 非常快、负载均衡</p>
<h4 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h4><p>环境：MAC OS 系统<br><code>brew install nginx</code></p>
<p>查看版本号：<br><code>nginx -V</code></p>
<p>启动：<br><code>nginx</code></p> 
      <a class="article-more-link" href="/2021/01/22/nginx/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/nginx/" rel="tag">nginx</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-vue3-lifecycle"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/13/vue3-lifecycle/"
    >Vue3的新特性(二)：生命周期</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/01/13/vue3-lifecycle/" class="article-date">
  <time datetime="2021-01-13T14:38:44.000Z" itemprop="datePublished">2021-01-13</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/VUE/">VUE</a> / <a class="article-category-link" href="/categories/VUE/VUE3/">VUE3</a> / <a class="article-category-link" href="/categories/VUE/VUE3/%E6%96%B0%E7%89%B9%E6%80%A7/">新特性</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="生命周期钩子函数"><a href="#生命周期钩子函数" class="headerlink" title="生命周期钩子函数"></a>生命周期钩子函数</h3><p>vue3 更新了生命周期钩子函数。<br>可以直接通过 import 对应的函数（例如：onMounted）来注册生命周期钩子函数。</p>
<p>Options API -&gt; Hook inside <code>setup</code></p>
<ol>
<li><del>beforeCreate</del> -&gt; use setup()</li>
<li><del>created</del> -&gt; use setup()</li>
<li>beforeMount -&gt; onBeforeMount</li>
<li>mounted -&gt; onMounted</li>
<li>beforeUpdate -&gt; onBeforeUpdate</li>
<li>updated -&gt; onUpdated</li>
<li>beforeUnmount -&gt; onBeforeUnmount</li>
<li>unmounted -&gt; onUnmounted</li>
<li>errorCaptured -&gt; onErrorCaptured</li>
<li>renderTracked -&gt; onRenderTracked（调试用）</li>
<li>renderTriggered -&gt; onRenderTriggered（调试用）</li>
</ol>
<p>因为 setup 是在 beforeCreated 和 created 几乎是同时进行的，所以可以将在这两个生命周期里的代码写在 setup 里面。</p> 
      <a class="article-more-link" href="/2021/01/13/vue3-lifecycle/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE/" rel="tag">VUE</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE3/" rel="tag">VUE3</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-vue3-02"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/13/vue3-02/"
    >Vue3的新特性(三)：setup()、computed()和watch()</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/01/13/vue3-02/" class="article-date">
  <time datetime="2021-01-13T14:16:42.000Z" itemprop="datePublished">2021-01-13</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/VUE/">VUE</a> / <a class="article-category-link" href="/categories/VUE/VUE3/">VUE3</a> / <a class="article-category-link" href="/categories/VUE/VUE3/%E6%96%B0%E7%89%B9%E6%80%A7/">新特性</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>本文主要介绍 vue3 新增 Composition API 的一些特性 setup()、computed()和 watch()，Composition API 可以把复杂组件的逻辑变得更为紧凑，使代码有更高复用性和灵活性。</p>
<h3 id="1-setup"><a href="#1-setup" class="headerlink" title="1. setup()"></a>1. setup()</h3><p><code>setup()</code>是 <code>vue3</code> 中新增特性，在组件 <code>created()</code>生命周期之前执行。<br>因为 <code>setup()</code> 是在组件 <code>created()</code>之前执行的，所以在 <code>setup()</code>内部无法获取 <code>this</code>。</p>
<p><code>setup(props,context)</code>接收两个参数：<code>props</code>,<code>context</code></p>
<h5 id="参数一：props"><a href="#参数一：props" class="headerlink" title="参数一：props"></a>参数一：props</h5><p>组件接收的 <code>props</code> 数据可以在 <code>setup()</code>函数内访问到。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">  <span class="attr">props</span>: &#123;</span><br><span class="line">    <span class="attr">title</span>: <span class="built_in">String</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="function"><span class="title">setup</span>(<span class="params">props</span>)</span> &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(props.title)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><code>props</code> 具有响应性，不能使用 ES6 解构它，这会使其失去响应性。如果需要解构，可以使用 <code>toRefs()</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> &#123; title &#125; = toRefs(props)</span><br><span class="line"><span class="built_in">console</span>.log(title.value)</span><br></pre></td></tr></table></figure>

<p>如果 <code>title</code> 是一个可选的属性，需使用 <code>toRef()</code>,如下：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> &#123; toRef &#125; <span class="keyword">from</span> <span class="string">&#x27;vue&#x27;</span></span><br><span class="line"><span class="function"><span class="title">setup</span>(<span class="params">props</span>)</span> &#123;</span><br><span class="line">	<span class="keyword">const</span> title = toRef(props, <span class="string">&#x27;title&#x27;</span>)</span><br><span class="line">	<span class="built_in">console</span>.log(title.value)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure> 
      <a class="article-more-link" href="/2021/01/13/vue3-02/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE/" rel="tag">VUE</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE3/" rel="tag">VUE3</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-vue3-01"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2021/01/12/vue3-01/"
    >Vue3 的新特性(一):ref()、reactive()、toRef() 和 toRefs()</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/01/12/vue3-01/" class="article-date">
  <time datetime="2021-01-12T15:28:58.000Z" itemprop="datePublished">2021-01-12</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/VUE/">VUE</a> / <a class="article-category-link" href="/categories/VUE/VUE3/">VUE3</a> / <a class="article-category-link" href="/categories/VUE/VUE3/%E6%96%B0%E7%89%B9%E6%80%A7/">新特性</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h5 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h5><p>vue3 更好的支持了 <code>Typescript</code>，新增了 <code>CompositionAPI</code>，而且在性能方面有很大提升</p>
<ol>
<li>打包大小减少 41%</li>
<li>初次渲染快 55%，更新快 133%</li>
<li>内存使用减少 54%</li>
</ol>
<p>这篇文章主要来学习以下 vue3 的以下新特性：<code>ref()</code>、<code>reactive()</code>、<code>toRef()</code>、<code>toRefs()</code></p>
<h5 id="版本要求"><a href="#版本要求" class="headerlink" title="版本要求"></a>版本要求</h5><p>对于 Vue3，node 版本 10+、Vue Cli v4.5+的版本可用。已经安装过<code>@vue/cli</code>需更新至最新版本</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">yarn <span class="built_in">global</span> add @vue/cli</span><br><span class="line">#or</span><br><span class="line">npm install -g @vue/cli</span><br></pre></td></tr></table></figure>

<h5 id="配置-Vue3-开发环境"><a href="#配置-Vue3-开发环境" class="headerlink" title="配置 Vue3 开发环境"></a>配置 Vue3 开发环境</h5><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vue create [project-name]</span><br></pre></td></tr></table></figure> 
      <a class="article-more-link" href="/2021/01/12/vue3-01/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE/" rel="tag">VUE</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/VUE3/" rel="tag">VUE3</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-react-ts-d3"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/11/18/react-ts-d3/"
    >React-ts-d3 项目实践</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2020/11/18/react-ts-d3/" class="article-date">
  <time datetime="2020-11-18T14:33:38.000Z" itemprop="datePublished">2020-11-18</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/React/">React</a> / <a class="article-category-link" href="/categories/React/Typescript/">Typescript</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>自从涉足了知识图谱项目便一发不可收拾，本次项目中也是涉及到一些可视化和知识图谱的元素，对我来说虽不是新的技术领域但是这次改用了 <code>ts</code>，所以还是踩了不少的坑呢，主要集中在 <code>d3</code> 和 <code>ts</code> 结合部分。</p>
<p>其次在项目评审期间，前端主要问题还有自适应方面的问题，最终敲定使用断点媒体查询的方式实现。</p>
<p>近期 <code>bug</code> 修复进入尾声，时隔数日还是复盘一下，毕竟我的脑瓜子还是一如既往的健忘，刚刚被问及一个项目是不是我做的，我记得是我做的，但是具体内容什么的我已经无力想起了，不过看到我还是认识的。言归正传，下面就来回顾一下踩坑流水帐。</p>
<h3 id="1-Echarts-Graph"><a href="#1-Echarts-Graph" class="headerlink" title="1. Echarts Graph"></a>1. Echarts Graph</h3><p>如果使用过 <code>echart</code> 系列图表，那么 <code>graph</code> 关系图还是相对比较容易上手的，毕竟是高度可定制化套路一样同类型属性名也一样。</p> 
      <a class="article-more-link" href="/2020/11/18/react-ts-d3/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/d3/" rel="tag">d3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/react/" rel="tag">react</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/typescript/" rel="tag">typescript</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-react-share-bike"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/18/react-share-bike/"
    >React+AntD+Redux 的项目实战总结</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2020/07/18/react-share-bike/" class="article-date">
  <time datetime="2020-07-18T15:46:43.000Z" itemprop="datePublished">2020-07-18</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/React/">React</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <!-- ![1.jepg](1.jpeg) -->

<h5 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h5><p>最近用 <code>React Hook</code> 实战了一个 React 项目。今天来总结一下，因为都是拼凑的时间所以项目历时半个多月之久，通过本次学习进一步的熟悉了 <code>AntD</code> 常用组件的使用，业务功能（增删改查）的开发及百度地图 API、富文本组件的使用、权限设置模块，最重要的是把学习的 <code>React Hook</code> 落实到了项目中。</p> 
      <a class="article-more-link" href="/2020/07/18/react-share-bike/"
        >阅读更多...</a
      >
       
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/react/" rel="tag">react</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/">上一页</a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="page-number" href="/page/4/">4</a><a class="extend next" rel="next" href="/page/3/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2021
        <i class="ri-heart-fill heart_icon"></i> Lillian
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/assets/imgs/header.png" alt="默"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/travel">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/photos">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/10/01/about/">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/assets/imgs/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/assets/imgs/weixin.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"log":false,"model":{"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"position":"right","width":160,"height":300},"mobile":{"show":false,"scale":0.5}});</script></body>

</html>